<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QMenu Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QMenu Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QMenu class provides a menu widget for use in menu bars,
context menus, and other popup menus. <a href="#details">More...</a></p>

<p>Inherits <a href="qwidget.html">QWidget</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qmenu.html#QMenu">__init__</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qmenu.html#QMenu-2">__init__</a></b> (<i>self</i>, QString&#160;<i>title</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QAction <b><a href="qmenu.html#actionAt">actionAt</a></b> (<i>self</i>, QPoint)</li><li><div class="fn" /><b><a href="qmenu.html#actionEvent">actionEvent</a></b> (<i>self</i>, QActionEvent)</li><li><div class="fn" />QRect <b><a href="qmenu.html#actionGeometry">actionGeometry</a></b> (<i>self</i>, QAction)</li><li><div class="fn" />QAction <b><a href="qmenu.html#activeAction">activeAction</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#addAction">addAction</a></b> (<i>self</i>, QAction&#160;<i>action</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addAction-2">addAction</a></b> (<i>self</i>, QString&#160;<i>text</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addAction-3">addAction</a></b> (<i>self</i>, QIcon&#160;<i>icon</i>, QString&#160;<i>text</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addAction-4">addAction</a></b> (<i>self</i>, QString&#160;<i>text</i>, QObject&#160;<i>receiver</i>, SLOT()SLOT()&#160;<i>member</i>, QKeySequence&#160;<i>shortcut</i>&#160;=&#160;0)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addAction-5">addAction</a></b> (<i>self</i>, QString&#160;<i>text</i>, callable&#160;<i>receiver</i>, QKeySequence&#160;<i>shortcut</i>&#160;=&#160;0)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addAction-6">addAction</a></b> (<i>self</i>, QIcon&#160;<i>icon</i>, QString&#160;<i>text</i>, QObject&#160;<i>receiver</i>, SLOT()SLOT()&#160;<i>member</i>, QKeySequence&#160;<i>shortcut</i>&#160;=&#160;0)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addAction-7">addAction</a></b> (<i>self</i>, QIcon&#160;<i>icon</i>, QString&#160;<i>text</i>, callable&#160;<i>receiver</i>, QKeySequence&#160;<i>shortcut</i>&#160;=&#160;0)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addMenu">addMenu</a></b> (<i>self</i>, QMenu&#160;<i>menu</i>)</li><li><div class="fn" />QMenu <b><a href="qmenu.html#addMenu-2">addMenu</a></b> (<i>self</i>, QString&#160;<i>title</i>)</li><li><div class="fn" />QMenu <b><a href="qmenu.html#addMenu-3">addMenu</a></b> (<i>self</i>, QIcon&#160;<i>icon</i>, QString&#160;<i>title</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#addSeparator">addSeparator</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#changeEvent">changeEvent</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" /><b><a href="qmenu.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qmenu.html#columnCount">columnCount</a></b> (<i>self</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#defaultAction">defaultAction</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#enterEvent">enterEvent</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />bool <b><a href="qmenu.html#event">event</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />QAction <b><a href="qmenu.html#exec">exec_</a></b> (<i>self</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#exec-2">exec_</a></b> (<i>self</i>, QPoint&#160;<i>p</i>, QAction&#160;<i>action</i>&#160;=&#160;None)</li><li><div class="fn" />bool <b><a href="qmenu.html#focusNextPrevChild">focusNextPrevChild</a></b> (<i>self</i>, bool&#160;<i>next</i>)</li><li><div class="fn" /><b><a href="qmenu.html#hideEvent">hideEvent</a></b> (<i>self</i>, QHideEvent)</li><li><div class="fn" /><b><a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a></b> (<i>self</i>)</li><li><div class="fn" />QIcon <b><a href="qmenu.html#icon">icon</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#initStyleOption">initStyleOption</a></b> (<i>self</i>, QStyleOptionMenuItem&#160;<i>option</i>, QAction&#160;<i>action</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#insertMenu">insertMenu</a></b> (<i>self</i>, QAction&#160;<i>before</i>, QMenu&#160;<i>menu</i>)</li><li><div class="fn" />QAction <b><a href="qmenu.html#insertSeparator">insertSeparator</a></b> (<i>self</i>, QAction&#160;<i>before</i>)</li><li><div class="fn" />bool <b><a href="qmenu.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmenu.html#isTearOffEnabled">isTearOffEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#keyPressEvent">keyPressEvent</a></b> (<i>self</i>, QKeyEvent)</li><li><div class="fn" /><b><a href="qmenu.html#leaveEvent">leaveEvent</a></b> (<i>self</i>, QEvent)</li><li><div class="fn" />QAction <b><a href="qmenu.html#menuAction">menuAction</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#mouseMoveEvent">mouseMoveEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qmenu.html#mousePressEvent">mousePressEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qmenu.html#mouseReleaseEvent">mouseReleaseEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qmenu.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent)</li><li><div class="fn" /><b><a href="qmenu.html#popup">popup</a></b> (<i>self</i>, QPoint&#160;<i>p</i>, QAction&#160;<i>action</i>&#160;=&#160;None)</li><li><div class="fn" />bool <b><a href="qmenu.html#separatorsCollapsible">separatorsCollapsible</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#setActiveAction">setActiveAction</a></b> (<i>self</i>, QAction&#160;<i>act</i>)</li><li><div class="fn" /><b><a href="qmenu.html#setDefaultAction">setDefaultAction</a></b> (<i>self</i>, QAction)</li><li><div class="fn" /><b><a href="qmenu.html#setIcon">setIcon</a></b> (<i>self</i>, QIcon&#160;<i>icon</i>)</li><li><div class="fn" /><b><a href="qmenu.html#setNoReplayFor">setNoReplayFor</a></b> (<i>self</i>, QWidget&#160;<i>widget</i>)</li><li><div class="fn" /><b><a href="qmenu.html#setSeparatorsCollapsible">setSeparatorsCollapsible</a></b> (<i>self</i>, bool&#160;<i>collapse</i>)</li><li><div class="fn" /><b><a href="qmenu.html#setTearOffEnabled">setTearOffEnabled</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qmenu.html#setTitle">setTitle</a></b> (<i>self</i>, QString&#160;<i>title</i>)</li><li><div class="fn" />QSize <b><a href="qmenu.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#timerEvent">timerEvent</a></b> (<i>self</i>, QTimerEvent)</li><li><div class="fn" />QString <b><a href="qmenu.html#title">title</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmenu.html#wheelEvent">wheelEvent</a></b> (<i>self</i>, QWheelEvent)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QAction <b><a href="qmenu.html#exec-3">exec_</a></b> (list-of-QAction&#160;<i>actions</i>, QPoint&#160;<i>pos</i>, QAction&#160;<i>action</i>&#160;=&#160;None)</li><li><div class="fn" />QAction <b><a href="qmenu.html#exec-4">exec_</a></b> (list-of-QAction&#160;<i>actions</i>, QPoint&#160;<i>pos</i>, QAction&#160;<i>at</i>, QWidget&#160;<i>parent</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qmenu.html#aboutToHide">aboutToHide</a></b> ()</li><li><div class="fn" />void <b><a href="qmenu.html#aboutToShow">aboutToShow</a></b> ()</li><li><div class="fn" />void <b><a href="qmenu.html#hovered">hovered</a></b> (QAction *)</li><li><div class="fn" />void <b><a href="qmenu.html#triggered">triggered</a></b> (QAction *)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QMenu class provides a menu widget for use in menu bars,
context menus, and other popup menus.</p>
<p>A menu widget is a selection menu. It can be either a pull-down
menu in a menu bar or a standalone context menu. Pull-down menus
are shown by the menu bar when the user clicks on the respective
item or presses the specified shortcut key. Use <a href="qmenubar.html#addMenu">QMenuBar.addMenu</a>() to insert a menu
into a menu bar. Context menus are usually invoked by some special
keyboard key or by right-clicking. They can be executed either
asynchronously with <a href="qmenu.html#popup">popup</a>() or
synchronously with <a href="qmenu.html#exec">exec_</a>(). Menus can
also be invoked in response to button presses; these are just like
context menus except for how they are invoked.</p>
<table class="generic" width="100%">
<tr class="odd" valign="top">
<td><img alt="" src="images/plastique-menu.png" /></td>
<td><img alt="" src="images/windowsxp-menu.png" /></td>
<td><img alt="" src="images/macintosh-menu.png" /></td>
</tr>
</table>
<p class="figCaption">Fig. A menu shown in <a href="gallery-plastique.html">Plastique widget style</a>, <a href="gallery-windowsxp.html">Windows XP widget style</a>, and <a href="gallery-macintosh.html">Macintosh widget style</a>.</p>
<a id="actions" name="actions" />
<h3>Actions</h3>
<p>A menu consists of a list of action items. Actions are added
with the <a href="qmenu.html#addAction">addAction</a>(), <a href="qwidget.html#addActions">addActions</a>() and <a href="qwidget.html#insertAction">insertAction</a>() functions. An action
is represented vertically and rendered by <a href="qstyle.html">QStyle</a>. In addition, actions can have a text
label, an optional icon drawn on the very left side, and shortcut
key sequence such as "Ctrl+X".</p>
<p>The existing actions held by a menu can be found with <a href="qwidget.html#actions">actions</a>().</p>
<p>There are four kinds of action items: separators, actions that
show a submenu, widgets, and actions that perform an action.
Separators are inserted with <a href="qmenu.html#addSeparator">addSeparator</a>(), submenus with
<a href="qmenu.html#addMenu">addMenu</a>(), and all other items are
considered action items.</p>
<p>When inserting action items you usually specify a receiver and a
slot. The receiver will be notifed whenever the item is <a href="qaction.html#triggered">triggered()</a>. In addition, QMenu
provides two signals, <a class="compat" href="qmenu-qt3.html#activated">activated</a>() and <a class="compat" href="qmenu-qt3.html#highlighted">highlighted</a>(), which signal the <a href="qaction.html">QAction</a> that was triggered from the menu.</p>
<p>You clear a menu with <a href="qmenu.html#clear">clear</a>() and
remove individual action items with <a href="qwidget.html#removeAction">removeAction</a>().</p>
<p>A QMenu can also provide a tear-off menu. A tear-off menu is a
top-level window that contains a copy of the menu. This makes it
possible for the user to "tear off" frequently used menus and
position them in a convenient place on the screen. If you want this
functionality for a particular menu, insert a tear-off handle with
<a href="qmenu.html#tearOffEnabled-prop">setTearOffEnabled</a>().
When using tear-off menus, bear in mind that the concept isn't
typically used on Microsoft Windows so some users may not be
familiar with it. Consider using a <a href="qtoolbar.html">QToolBar</a> instead.</p>
<p>Widgets can be inserted into menus with the <a href="qwidgetaction.html">QWidgetAction</a> class. Instances of this
class are used to hold widgets, and are inserted into menus with
the <a href="qmenu.html#addAction">addAction</a>() overload that
takes a <a href="qaction.html">QAction</a>.</p>
<p>Conversely, actions can be added to widgets with the <a href="qmenu.html#addAction">addAction</a>(), <a href="qwidget.html#addActions">addActions</a>() and <a href="qwidget.html#insertAction">insertAction</a>() functions.</p>
<p><b>Warning:</b> To make QMenu visible on the screen, <a href="qmenu.html#exec">exec_</a>() or <a href="qmenu.html#popup">popup</a>() should be used instead of <a href="qwidget.html#show">show</a>().</p>
<a id="qmenu-on-qt-for-windows-ce" name="qmenu-on-qt-for-windows-ce" />
<h3>QMenu on Qt for Windows CE</h3>
<p>If a menu is integrated into the native menubar on Windows
Mobile we do not support the signals: aboutToHide (), aboutToShow
() and hovered (). It is not possible to display an icon in a
native menu on Windows Mobile.</p>
<a id="qmenu-on-mac-os-x-with-qt-build-against-cocoa" name="qmenu-on-mac-os-x-with-qt-build-against-cocoa" />
<h3>QMenu on Mac OS X with Qt build against Cocoa</h3>
<p>QMenu can be inserted only once in a menu/menubar. Subsequent
insertions will have no effect or will result in a disabled menu
item.</p>
<p>See the <a href="mainwindows-menus.html">Menus</a> example for
an example of how to use <a href="qmenubar.html">QMenuBar</a> and
QMenu in your application.</p>
<p><b>Important inherited functions:</b> <a href="qmenu.html#addAction">addAction</a>(), <a href="qwidget.html#removeAction">removeAction</a>(), <a href="qmenu.html#clear">clear</a>(), <a href="qmenu.html#addSeparator">addSeparator</a>(), and <a href="qmenu.html#addMenu">addMenu</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QMenu" />QMenu.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a menu with parent <i>parent</i>.</p>
<p>Although a popup menu is always a top-level widget, if a parent
is passed the popup menu will be deleted when that parent is
destroyed (as with any other <a href="qobject.html">QObject</a>).</p>


<h3 class="fn"><a name="QMenu-2" />QMenu.__init__ (<i>self</i>, QString&#160;<i>title</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a menu with a <i>title</i> and a <i>parent</i>.</p>
<p>Although a popup menu is always a top-level widget, if a parent
is passed the popup menu will be deleted when that parent is
destroyed (as with any other <a href="qobject.html">QObject</a>).</p>
<p><b>See also</b> <a href="qmenu.html#title-prop">title</a>.</p>


<h3 class="fn"><a name="actionAt" /><a href="qaction.html">QAction</a> QMenu.actionAt (<i>self</i>, <a href="qpoint.html">QPoint</a>)</h3><p>Returns the item at <i>pt</i>; returns 0 if there is no item
there.</p>


<h3 class="fn"><a name="actionEvent" />QMenu.actionEvent (<i>self</i>, <a href="qactionevent.html">QActionEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#actionEvent">QWidget.actionEvent</a>().</p>


<h3 class="fn"><a name="actionGeometry" /><a href="qrect.html">QRect</a> QMenu.actionGeometry (<i>self</i>, <a href="qaction.html">QAction</a>)</h3><p>Returns the geometry of action <i>act</i>.</p>


<h3 class="fn"><a name="activeAction" /><a href="qaction.html">QAction</a> QMenu.activeAction (<i>self</i>)</h3><p>Returns the currently highlighted action, or 0 if no action is
currently highlighted.</p>
<p><b>See also</b> <a href="qmenu.html#setActiveAction">setActiveAction</a>().</p>


<h3 class="fn"><a name="addAction" />QMenu.addAction (<i>self</i>, <a href="qaction.html">QAction</a>&#160;<i>action</i>)</h3><p>This is an overloaded function.</p>
<p>This convenience function creates a new action with <i>text</i>.
The function adds the newly created action to the menu's list of
actions, and returns it.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>


<h3 class="fn"><a name="addAction-2" /><a href="qaction.html">QAction</a> QMenu.addAction (<i>self</i>, QString&#160;<i>text</i>)</h3><p>This is an overloaded function.</p>
<p>This convenience function creates a new action with an
<i>icon</i> and some <i>text</i>. The function adds the newly
created action to the menu's list of actions, and returns it.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>


<h3 class="fn"><a name="addAction-3" /><a href="qaction.html">QAction</a> QMenu.addAction (<i>self</i>, <a href="qicon.html">QIcon</a>&#160;<i>icon</i>, QString&#160;<i>text</i>)</h3><p>This is an overloaded function.</p>
<p>This convenience function creates a new action with the text
<i>text</i> and an optional shortcut <i>shortcut</i>. The action's
<a href="qaction.html#triggered">triggered()</a> signal is
connected to the <i>receiver</i>'s <i>member</i> slot. The function
adds the newly created action to the menu's list of actions and
returns it.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>


<h3 class="fn"><a name="addAction-4" /><a href="qaction.html">QAction</a> QMenu.addAction (<i>self</i>, QString&#160;<i>text</i>, <a href="qobject.html">QObject</a>&#160;<i>receiver</i>, SLOT()SLOT()&#160;<i>member</i>, <a href="qkeysequence.html">QKeySequence</a>&#160;<i>shortcut</i>&#160;=&#160;0)</h3><p>This is an overloaded function.</p>
<p>This convenience function creates a new action with an
<i>icon</i> and some <i>text</i> and an optional shortcut
<i>shortcut</i>. The action's <a href="qaction.html#triggered">triggered()</a> signal is connected to the
<i>member</i> slot of the <i>receiver</i> object. The function adds
the newly created action to the menu's list of actions, and returns
it.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>


<h3 class="fn"><a name="addAction-5" /><a href="qaction.html">QAction</a> QMenu.addAction (<i>self</i>, QString&#160;<i>text</i>, callable&#160;<i>receiver</i>, <a href="qkeysequence.html">QKeySequence</a>&#160;<i>shortcut</i>&#160;=&#160;0)</h3><p>This is an overloaded function.</p>
<p>Appends the action <i>action</i> to the menu's list of
actions.</p>
<p><b>See also</b> <a href="qmenubar.html#addAction">QMenuBar.addAction</a>() and <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>


<h3 class="fn"><a name="addAction-6" /><a href="qaction.html">QAction</a> QMenu.addAction (<i>self</i>, <a href="qicon.html">QIcon</a>&#160;<i>icon</i>, QString&#160;<i>text</i>, <a href="qobject.html">QObject</a>&#160;<i>receiver</i>, SLOT()SLOT()&#160;<i>member</i>, <a href="qkeysequence.html">QKeySequence</a>&#160;<i>shortcut</i>&#160;=&#160;0)</h3><h3 class="fn"><a name="addAction-7" /><a href="qaction.html">QAction</a> QMenu.addAction (<i>self</i>, <a href="qicon.html">QIcon</a>&#160;<i>icon</i>, QString&#160;<i>text</i>, callable&#160;<i>receiver</i>, <a href="qkeysequence.html">QKeySequence</a>&#160;<i>shortcut</i>&#160;=&#160;0)</h3><h3 class="fn"><a name="addMenu" /><a href="qaction.html">QAction</a> QMenu.addMenu (<i>self</i>, <a href="qmenu.html">QMenu</a>&#160;<i>menu</i>)</h3><p>This convenience function adds <i>menu</i> as a submenu to this
menu. It returns <i>menu</i>'s <a href="qmenu.html#menuAction">menuAction</a>(). This menu does not take
ownership of <i>menu</i>.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>() and <a href="qmenu.html#menuAction">QMenu.menuAction</a>().</p>


<h3 class="fn"><a name="addMenu-2" /><a href="qmenu.html">QMenu</a> QMenu.addMenu (<i>self</i>, QString&#160;<i>title</i>)</h3><p>Appends a new <a href="qmenu.html">QMenu</a> with <i>title</i>
to the menu. The menu takes ownership of the menu. Returns the new
menu.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>() and <a href="qmenu.html#menuAction">QMenu.menuAction</a>().</p>


<h3 class="fn"><a name="addMenu-3" /><a href="qmenu.html">QMenu</a> QMenu.addMenu (<i>self</i>, <a href="qicon.html">QIcon</a>&#160;<i>icon</i>, QString&#160;<i>title</i>)</h3><p>Appends a new <a href="qmenu.html">QMenu</a> with <i>icon</i>
and <i>title</i> to the menu. The menu takes ownership of the menu.
Returns the new menu.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>() and <a href="qmenu.html#menuAction">QMenu.menuAction</a>().</p>


<h3 class="fn"><a name="addSeparator" /><a href="qaction.html">QAction</a> QMenu.addSeparator (<i>self</i>)</h3><p>This convenience function creates a new separator action, i.e.
an action with <a href="qaction.html#isSeparator">QAction.isSeparator</a>() returning
true, and adds the new action to this menu's list of actions. It
returns the newly created action.</p>
<p><b>See also</b> <a href="qwidget.html#addAction">QWidget.addAction</a>().</p>


<h3 class="fn"><a name="changeEvent" />QMenu.changeEvent (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget.changeEvent</a>().</p>


<h3 class="fn"><a name="clear" />QMenu.clear (<i>self</i>)</h3><p>Removes all the menu's actions. Actions owned by the menu and
not shown in any other widget are deleted.</p>
<p><b>See also</b> <a href="qwidget.html#removeAction">removeAction</a>().</p>


<h3 class="fn"><a name="columnCount" />int QMenu.columnCount (<i>self</i>)</h3><p>If a menu does not fit on the screen it lays itself out so that
it does fit. It is style dependent what layout means (for example,
on Windows it will use multiple columns).</p>
<p>This functions returns the number of columns necessary.</p>


<h3 class="fn"><a name="defaultAction" /><a href="qaction.html">QAction</a> QMenu.defaultAction (<i>self</i>)</h3><p>Returns the current default action.</p>
<p><b>See also</b> <a href="qmenu.html#setDefaultAction">setDefaultAction</a>().</p>


<h3 class="fn"><a name="enterEvent" />QMenu.enterEvent (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#enterEvent">QWidget.enterEvent</a>().</p>


<h3 class="fn"><a name="event" />bool QMenu.event (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>


<h3 class="fn"><a name="exec" /><a href="qaction.html">QAction</a> QMenu.exec_ (<i>self</i>)</h3><p>Executes this menu synchronously.</p>
<p>This is equivalent to <tt>exec(pos())</tt>.</p>
<p>This returns the triggered <a href="qaction.html">QAction</a> in
either the popup menu or one of its submenus, or 0 if no item was
triggered (normally because the user pressed Esc).</p>
<p>In most situations you'll want to specify the position yourself,
for example, the current mouse position:</p>
<pre class="cpp">
 exec(<span class="type"><a href="qcursor.html">QCursor</a></span><span class="operator">.</span>pos());
</pre>
<p>or aligned to a widget:</p>
<pre class="cpp">
 exec(somewidget<span class="operator">.</span>mapToGlobal(<span class="type"><a href="qpoint.html">QPoint</a></span>(<span class="number">0</span><span class="operator">,</span><span class="number">0</span>)));
</pre>
<p>or in reaction to a <a href="qmouseevent.html">QMouseEvent</a>
*e:</p>
<pre class="cpp">
 exec(e<span class="operator">-</span><span class="operator">&gt;</span>globalPos());
</pre>


<h3 class="fn"><a name="exec-2" /><a href="qaction.html">QAction</a> QMenu.exec_ (<i>self</i>, <a href="qpoint.html">QPoint</a>&#160;<i>p</i>, <a href="qaction.html">QAction</a>&#160;<i>action</i>&#160;=&#160;None)</h3><p>This is an overloaded function.</p>
<p>Executes this menu synchronously.</p>
<p>Pops up the menu so that the action <i>action</i> will be at the
specified <i>global</i> position <i>p</i>. To translate a widget's
local coordinates into global coordinates, use <a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>().</p>
<p>This returns the triggered <a href="qaction.html">QAction</a> in
either the popup menu or one of its submenus, or 0 if no item was
triggered (normally because the user pressed Esc).</p>
<p>Note that all signals are emitted as usual. If you connect a
<a href="qaction.html">QAction</a> to a slot and call the menu's
<a href="qmenu.html#exec">exec_</a>(), you get the result both via
the signal-slot connection and in the return value of <a href="qmenu.html#exec">exec_</a>().</p>
<p>Common usage is to position the menu at the current mouse
position:</p>
<pre class="cpp">
 <a href="qmenu.html#exec">exec_</a>(<span class="type"><a href="qcursor.html">QCursor</a></span><span class="operator">.</span>pos());
</pre>
<p>or aligned to a widget:</p>
<pre class="cpp">
 <a href="qmenu.html#exec">exec_</a>(somewidget<span class="operator">.</span>mapToGlobal(<span class="type"><a href="qpoint.html">QPoint</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span>)));
</pre>
<p>or in reaction to a <a href="qmouseevent.html">QMouseEvent</a>
*e:</p>
<pre class="cpp">
 <a href="qmenu.html#exec">exec_</a>(e<span class="operator">-</span><span class="operator">&gt;</span>globalPos());
</pre>
<p>When positioning a menu with <a href="qmenu.html#exec">exec_</a>() or <a href="qmenu.html#popup">popup</a>(), bear in mind that you cannot rely
on the menu's current <a href="qwidget.html#size-prop">size</a>().
For performance reasons, the menu adapts its size only when
necessary. So in many cases, the size before and after the show is
different. Instead, use <a href="qmenu.html#sizeHint">sizeHint</a>() which calculates the proper
size depending on the menu's current contents.</p>
<p><b>See also</b> <a href="qmenu.html#popup">popup</a>() and
<a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>().</p>


<h3 class="fn"><a name="exec-3" /><a href="qaction.html">QAction</a> QMenu.exec_ (list-of-QAction&#160;<i>actions</i>, <a href="qpoint.html">QPoint</a>&#160;<i>pos</i>, <a href="qaction.html">QAction</a>&#160;<i>action</i>&#160;=&#160;None)</h3><p>This is an overloaded function.</p>
<p>Executes a menu synchronously.</p>
<p>The menu's actions are specified by the list of <i>actions</i>.
The menu will pop up so that the specified action, <i>at</i>,
appears at global position <i>pos</i>. If <i>at</i> is not
specified then the menu appears at position <i>pos</i>.
<i>parent</i> is the menu's parent widget; specifying the parent
will provide context when <i>pos</i> alone is not enough to decide
where the menu should go (e.g., with multiple desktops or when the
parent is embedded in <a href="qgraphicsview.html">QGraphicsView</a>).</p>
<p>The function returns the triggered <a href="qaction.html">QAction</a> in either the popup menu or one of its
submenus, or 0 if no item was triggered (normally because the user
pressed Esc).</p>
<p>This is equivalent to:</p>
<pre class="cpp">
 <span class="type"><a href="qmenu.html">QMenu</a></span> menu;
 <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>at <span class="operator">=</span> actions<span class="operator">[</span><span class="number">0</span><span class="operator">]</span>; <span class="comment">// Assumes actions is not empty</span>
 <a href="qtcore.html#foreach">foreach</a> (<span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>a<span class="operator">,</span> actions)
     menu<span class="operator">.</span><a href="qmenu.html#addAction">addAction</a>(a);
 menu<span class="operator">.</span><a href="qmenu.html#exec">exec_</a>(pos<span class="operator">,</span> at);
</pre>
<p><b>See also</b> <a href="qmenu.html#popup">popup</a>() and
<a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>().</p>


<h3 class="fn"><a name="exec-4" /><a href="qaction.html">QAction</a> QMenu.exec_ (list-of-QAction&#160;<i>actions</i>, <a href="qpoint.html">QPoint</a>&#160;<i>pos</i>, <a href="qaction.html">QAction</a>&#160;<i>at</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>)</h3><p>This is an overloaded function.</p>
<p>Executes a menu synchronously.</p>
<p>The menu's actions are specified by the list of <i>actions</i>.
The menu will pop up so that the specified action, <i>at</i>,
appears at global position <i>pos</i>. If <i>at</i> is not
specified then the menu appears at position <i>pos</i>.</p>
<p>The function returns the triggered <a href="qaction.html">QAction</a> in either the popup menu or one of its
submenus, or 0 if no item was triggered (normally because the user
pressed Esc).</p>
<p>This is equivalent to:</p>
<pre class="cpp">
 <span class="type"><a href="qmenu.html">QMenu</a></span> menu;
 <span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>at <span class="operator">=</span> actions<span class="operator">[</span><span class="number">0</span><span class="operator">]</span>; <span class="comment">// Assumes actions is not empty</span>
 <a href="qtcore.html#foreach">foreach</a> (<span class="type"><a href="qaction.html">QAction</a></span> <span class="operator">*</span>a<span class="operator">,</span> actions)
     menu<span class="operator">.</span><a href="qmenu.html#addAction">addAction</a>(a);
 menu<span class="operator">.</span><a href="qmenu.html#exec">exec_</a>(pos<span class="operator">,</span> at);
</pre>
<p><b>See also</b> <a href="qmenu.html#popup">popup</a>() and
<a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>().</p>


<h3 class="fn"><a name="focusNextPrevChild" />bool QMenu.focusNextPrevChild (<i>self</i>, bool&#160;<i>next</i>)</h3><p>Reimplemented from <a href="qwidget.html#focusNextPrevChild">QWidget.focusNextPrevChild</a>().</p>


<h3 class="fn"><a name="hideEvent" />QMenu.hideEvent (<i>self</i>, <a href="qhideevent.html">QHideEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#hideEvent">QWidget.hideEvent</a>().</p>


<h3 class="fn"><a name="hideTearOffMenu" />QMenu.hideTearOffMenu (<i>self</i>)</h3><p>This function will forcibly hide the torn off menu making it
disappear from the users desktop.</p>
<p><b>See also</b> <a href="qmenu.html#isTearOffMenuVisible">isTearOffMenuVisible</a>() and
<a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>


<h3 class="fn"><a name="icon" /><a href="qicon.html">QIcon</a> QMenu.icon (<i>self</i>)</h3><h3 class="fn"><a name="initStyleOption" />QMenu.initStyleOption (<i>self</i>, <a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a>&#160;<i>option</i>, <a href="qaction.html">QAction</a>&#160;<i>action</i>)</h3><p>Initialize <i>option</i> with the values from this menu and
information from <i>action</i>. This method is useful for
subclasses when they need a <a href="qstyleoptionmenuitem.html">QStyleOptionMenuItem</a>, but don't
want to fill in all the information themselves.</p>
<p><b>See also</b> <a href="qstyleoption.html#initFrom">QStyleOption.initFrom</a>() and
<a href="qmenubar.html#initStyleOption">QMenuBar.initStyleOption</a>().</p>


<h3 class="fn"><a name="insertMenu" /><a href="qaction.html">QAction</a> QMenu.insertMenu (<i>self</i>, <a href="qaction.html">QAction</a>&#160;<i>before</i>, <a href="qmenu.html">QMenu</a>&#160;<i>menu</i>)</h3><p>This convenience function inserts <i>menu</i> before action
<i>before</i> and returns the menus <a href="qmenu.html#menuAction">menuAction</a>().</p>
<p><b>See also</b> <a href="qwidget.html#insertAction">QWidget.insertAction</a>() and
<a href="qmenu.html#addMenu">addMenu</a>().</p>


<h3 class="fn"><a name="insertSeparator" /><a href="qaction.html">QAction</a> QMenu.insertSeparator (<i>self</i>, <a href="qaction.html">QAction</a>&#160;<i>before</i>)</h3><p>This convenience function creates a new separator action, i.e.
an action with <a href="qaction.html#isSeparator">QAction.isSeparator</a>() returning
true. The function inserts the newly created action into this
menu's list of actions before action <i>before</i> and returns
it.</p>
<p><b>See also</b> <a href="qwidget.html#insertAction">QWidget.insertAction</a>() and
<a href="qmenu.html#addSeparator">addSeparator</a>().</p>


<h3 class="fn"><a name="isEmpty" />bool QMenu.isEmpty (<i>self</i>)</h3><p>Returns true if there are no visible actions inserted into the
menu, false otherwise.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qwidget.html#actions">QWidget.actions</a>().</p>


<h3 class="fn"><a name="isTearOffEnabled" />bool QMenu.isTearOffEnabled (<i>self</i>)</h3><h3 class="fn"><a name="isTearOffMenuVisible" />bool QMenu.isTearOffMenuVisible (<i>self</i>)</h3><p>When a menu is torn off a second menu is shown to display the
menu contents in a new window. When the menu is in this mode and
the menu is visible returns true; otherwise false.</p>
<p><b>See also</b> <a href="qmenu.html#hideTearOffMenu">hideTearOffMenu</a>() and <a href="qmenu.html#tearOffEnabled-prop">isTearOffEnabled</a>().</p>


<h3 class="fn"><a name="keyPressEvent" />QMenu.keyPressEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget.keyPressEvent</a>().</p>


<h3 class="fn"><a name="leaveEvent" />QMenu.leaveEvent (<i>self</i>, <a href="qevent.html">QEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#leaveEvent">QWidget.leaveEvent</a>().</p>


<h3 class="fn"><a name="menuAction" /><a href="qaction.html">QAction</a> QMenu.menuAction (<i>self</i>)</h3><p>Returns the action associated with this menu.</p>


<h3 class="fn"><a name="mouseMoveEvent" />QMenu.mouseMoveEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#mouseMoveEvent">QWidget.mouseMoveEvent</a>().</p>


<h3 class="fn"><a name="mousePressEvent" />QMenu.mousePressEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget.mousePressEvent</a>().</p>


<h3 class="fn"><a name="mouseReleaseEvent" />QMenu.mouseReleaseEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#mouseReleaseEvent">QWidget.mouseReleaseEvent</a>().</p>


<h3 class="fn"><a name="paintEvent" />QMenu.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget.paintEvent</a>().</p>


<h3 class="fn"><a name="popup" />QMenu.popup (<i>self</i>, <a href="qpoint.html">QPoint</a>&#160;<i>p</i>, <a href="qaction.html">QAction</a>&#160;<i>action</i>&#160;=&#160;None)</h3><p>Displays the menu so that the action <i>atAction</i> will be at
the specified <i>global</i> position <i>p</i>. To translate a
widget's local coordinates into global coordinates, use <a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>().</p>
<p>When positioning a menu with <a href="qmenu.html#exec">exec_</a>() or popup(), bear in mind that you
cannot rely on the menu's current <a href="qwidget.html#size-prop">size</a>(). For performance reasons, the
menu adapts its size only when necessary, so in many cases, the
size before and after the show is different. Instead, use <a href="qmenu.html#sizeHint">sizeHint</a>() which calculates the proper
size depending on the menu's current contents.</p>
<p><b>See also</b> <a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>() and <a href="qmenu.html#exec">exec_</a>().</p>


<h3 class="fn"><a name="separatorsCollapsible" />bool QMenu.separatorsCollapsible (<i>self</i>)</h3><h3 class="fn"><a name="setActiveAction" />QMenu.setActiveAction (<i>self</i>, <a href="qaction.html">QAction</a>&#160;<i>act</i>)</h3><p>Sets the currently highlighted action to <i>act</i>.</p>
<p><b>See also</b> <a href="qmenu.html#activeAction">activeAction</a>().</p>


<h3 class="fn"><a name="setDefaultAction" />QMenu.setDefaultAction (<i>self</i>, <a href="qaction.html">QAction</a>)</h3><p>This sets the default action to <i>act</i>. The default action
may have a visual cue, depending on the current <a href="qstyle.html">QStyle</a>. A default action usually indicates what
will happen by default when a drop occurs.</p>
<p><b>See also</b> <a href="qmenu.html#defaultAction">defaultAction</a>().</p>


<h3 class="fn"><a name="setIcon" />QMenu.setIcon (<i>self</i>, <a href="qicon.html">QIcon</a>&#160;<i>icon</i>)</h3><h3 class="fn"><a name="setNoReplayFor" />QMenu.setNoReplayFor (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>widget</i>)</h3><h3 class="fn"><a name="setSeparatorsCollapsible" />QMenu.setSeparatorsCollapsible (<i>self</i>, bool&#160;<i>collapse</i>)</h3><h3 class="fn"><a name="setTearOffEnabled" />QMenu.setTearOffEnabled (<i>self</i>, bool)</h3><h3 class="fn"><a name="setTitle" />QMenu.setTitle (<i>self</i>, QString&#160;<i>title</i>)</h3><h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QMenu.sizeHint (<i>self</i>)</h3><p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget.sizeHint</a>().</p>


<h3 class="fn"><a name="timerEvent" />QMenu.timerEvent (<i>self</i>, <a href="qtimerevent.html">QTimerEvent</a>)</h3><p>Reimplemented from <a href="qobject.html#timerEvent">QObject.timerEvent</a>().</p>


<h3 class="fn"><a name="title" />QString QMenu.title (<i>self</i>)</h3><h3 class="fn"><a name="wheelEvent" />QMenu.wheelEvent (<i>self</i>, <a href="qwheelevent.html">QWheelEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#wheelEvent">QWidget.wheelEvent</a>().</p>
<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="aboutToHide" />void aboutToHide ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted just before the menu is hidden from the
user.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also</b> <a href="qmenu.html#aboutToShow">aboutToShow</a>() and <a href="qwidget.html#hide">hide</a>().</p>


<h3 class="fn"><a name="aboutToShow" />void aboutToShow ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted just before the menu is shown to the
user.</p>
<p><b>See also</b> <a href="qmenu.html#aboutToHide">aboutToHide</a>() and <a href="qwidget.html#show">show</a>().</p>


<h3 class="fn"><a name="hovered" />void hovered (QAction *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when a menu action is highlighted;
<i>action</i> is the action that caused the signal to be
emitted.</p>
<p>Often this is used to update status information.</p>
<p><b>See also</b> <a href="qmenu.html#triggered">triggered</a>()
and <a href="qaction.html#hovered">QAction.hovered</a>().</p>


<h3 class="fn"><a name="triggered" />void triggered (QAction *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when an action in this menu is
triggered.</p>
<p><i>action</i> is the action that caused the signal to be
emitted.</p>
<p>Normally, you connect each menu action's <a href="qaction.html#triggered">triggered()</a> signal to its own custom
slot, but sometimes you will want to connect several actions to a
single slot, for example, when you have a group of closely related
actions, such as "left justify", "center", "right justify".</p>
<p><b>Note:</b> This signal is emitted for the main parent menu in
a hierarchy. Hence, only the parent menu needs to be connected to a
slot; sub-menus need not be connected.</p>
<p><b>See also</b> <a href="qmenu.html#hovered">hovered</a>() and
<a href="qaction.html#triggered">QAction.triggered</a>().</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>